package com.hk.enums;

import lombok.Data;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;

@Getter
public enum OuterErrorEnum {

    PARAM_ISNULL_ERROR(1000,"入参为空异常"),
    PARAM_VALUE_ISERROR(1001,"入参不正确"),
    FACTORY_PARAM_ISNULL_ERROR(1002,"获取消息实现失败，参数错误！"),
    FACTORY_MAP_ISNULL_ERROR(1002,"获取消息实现失败，Map为空！"),
    INTERFACE_ALREADY_LIMIT(5000,"接口已经被限流！"),
    PARAM_ISNULL_ERROR_USERNAME(1000,"用户名为空异常")
    ;

    private Integer code;

    private String msg;


    public static OuterErrorEnum getErrorEnumByName(String name) {
        if (StringUtils.isBlank(name)) {
            return null;
        }
        for (OuterErrorEnum errorEnum : values()) {
            if (errorEnum.name().equals(name)) {
                return errorEnum;
            }
        }
        return null;
    }


    OuterErrorEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

}
